package com.ann.concurrent;

import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author Ann
 * @title: VolatileVisibiletyTest
 * @projectName interview_synthesis
 * @description:
 * @date 2020/7/6 22:34
 */
public class VolatileVisibiletyTest {

//    private static boolean initData = false;
    private static volatile boolean  initData = false;

    public static void main(String[] args) throws InterruptedException {
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("waiting data........");
                while (!initData){

                }
                System.out.println("====success======");
            }
        }).start();


        Thread.sleep(2000);

        new Thread(new Runnable() {
            @Override
            public void run() {
                prapareData();
            }
        }).start();
    }


    public static void prapareData(){
        System.out.println("prepare data....");
        initData = true;
        System.out.println("prepare data..end");
    }
}
